
*** This do file includes regressions based on district-level data for the paper "Foreign Interventions and Community Cohesion in Times of Conflict"	
*** Author: Sarah Langlotz		
*** Journal: Journal of Development Economics
													

***********************************************************************************************
**************************************Read me **************************************
***********************************************************************************************
*** FOLDER STRUCTURE
/* After downloading the data from the Harvard Dataverse, create the following three folders:
	- "processed"
	- "graphs"
	- "tables"
*/



***	SOFTWARE VERSION
*	Stata/MP 19.0 for Windows (64-bit x86-64), Revision 21 May 2025



***	TABLES
* 	This dofiles creates Table 5


***********************************************************************************
***	Set your directory

local DIR = ""
cap cd "`DIR'"

***********************************************************************************

drop _all
clear matrix
clear mata
set maxvar 10000
set matsize 10000

set more off

clear
clear
use "processed\final_districtlevel_external.dta"


********************************************************************************
* TABLE 5 - Panel: Counterinsurgency, 2005-2010 (Panel A-E)
********************************************************************************



cap drop ISAF
gen double ISAF = .


cap est drop *

foreach Y of varlist lnallsigacts lnbest_est lndeaths_civilians lndeaths_civilianssb  {

    local i = 1
    
    foreach x of varlist largebase_inbr activebase no_securityprt   {

        * ----- contemporaneous ISAF -----
        replace ISAF = `x'

        reghdfe `Y' ISAF  if year>2004 & year<2011, absorb(id i.year) cluster(districtcode)
		estadd local lag "No"
		estadd local control "Yes"
        estadd local restr "Yes"
        est store est`i'_`Y'
        local ++i

        * ----- lagged ISAF -----
        replace ISAF = l1`x'

        reghdfe `Y' ISAF  if year>2004 & year<2011, absorb(id i.year) cluster(districtcode)
  		estadd local lag "Yes"
		estadd local control "Yes"
        estadd local restr "Yes"
        est store est`i'_`Y'
        local ++i
    }

    esttab est1_`Y' est2_`Y' est3_`Y' est4_`Y' est5_`Y' est6_`Y' ///
        using "tables/conflict_district_`Y'.tex", ///
        fragment booktabs se(3) b(3) star starlevels(* 0.10 ** 0.05 *** 0.01) replace ///
        mlabel(none) style(fixed) keep(ISAF) order(ISAF) ///
        varlabel(ISAF "ISAF") ///
        stats(r2_a, fmt( 3) label( "Adj. R$^2$")) ///
        nonumbers nogaps noabbr nolines nomtitle nonote 
}

	cap est drop *
foreach Y of varlist lndeaths_civiliansns {

    local i = 1
    
    foreach x of varlist largebase_inbr activebase no_securityprt   {

        * ----- contemporaneous ISAF -----
        replace ISAF = `x'

        reghdfe `Y' ISAF  if year>2004 & year<2011, absorb(id i.year) cluster(districtcode)
		estadd local lag "No"
		estadd local control "Yes"
        estadd local restr "Yes"
        est store est`i'_`Y'
        local ++i

        * ----- lagged ISAF -----
        replace ISAF = l1`x'

        reghdfe `Y' ISAF  if year>2004 & year<2011, absorb(id i.year) cluster(districtcode)
  		estadd local lag "Yes"
		estadd local control "Yes"
        estadd local restr "Yes"
        est store est`i'_`Y'
        local ++i
    }

    esttab est1_`Y' est2_`Y' est3_`Y' est4_`Y' est5_`Y' est6_`Y' ///
        using "tables/conflict_district_`Y'.tex", ///
        fragment booktabs se(3) b(3) star starlevels(* 0.10 ** 0.05 *** 0.01) replace ///
        mlabel(none) style(fixed) keep(ISAF) order(ISAF) ///
        varlabel(ISAF "ISAF") ///
        stats(r2_a N , fmt(3 0 ) label( "Adj. R$^2$" "\hline Observations")) ///
        nonumbers nogaps noabbr nolines nomtitle nonote 
}

